﻿#region Using Statements
using System;
using GameBase.Screens;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace StarFox.ScreenComponents
{
    /// <summary>
    /// Basic properties needed to implement any 2D content.
    /// </summary>
    public abstract class ScreenComponent2D
    {
        #region Properties

        /// <summary>
        /// Gets the game that this component is associated to.
        /// </summary>
        public Game Game
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets the Screen that this ScreenComponent2D is associated to.
        /// </summary>
        public Screen Screen
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets the SpriteBatch that this ScreenComponent2D is associated to.
        /// </summary>
        public SpriteBatch SpriteBatch
        {
            get;
            private set;
        }

        #endregion

        #region Screen Transitions

        /// <summary>
        /// Makes the ScreenComponent2D transition to visible state.
        /// <para>Override this method with component-specific transition code.</para>
        /// </summary>
        public abstract void Show();

        /// <summary>
        /// Makes the ScreenComponent2D transition to hidden state.
        /// <para>Override this method with component-specific transition code.</para>
        /// </summary>
        public abstract void Hide();

        /// <summary>
        /// Gets the time needed for a Screen to transition (in or out).
        /// </summary>
        public TimeSpan Time
        {
            get;
            private set;
        }
        
        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="screen">The Screen that this ScreenComponent2D is associated to.</param>
        public ScreenComponent2D(Screen screen)
        {
            Game = screen.Game;
            Screen = screen;
            SpriteBatch = Screen.SpriteBatch;
            Time = Screen.ScreenManager.Time;
        }

        #endregion

        #region Update

        /// <summary>
        /// Called when the ScreenComponent2D needs to be updated.
        /// <para>Override this method with component-specific update code.</para>
        /// </summary>
        /// <param name="gameTime">Time elapsed since the last call to this method.</param>
        public abstract void Update(GameTime gameTime);

        #endregion

        #region Draw

        /// <summary>
        /// Called when the ScreenComponent2D needs to be drawn.
        /// <para>Override this method with component-specific drawing code.</para>
        /// </summary>
        /// <param name="gameTime">Time elapsed since the last call to this method.</param>
        public abstract void Draw(GameTime gameTime);

        #endregion
    }
}
